package com.ivo.activiti.mysql;

import org.hibernate.dialect.MySQL5Dialect;

/**
 * 重写数据库方言
 * 解决hibernate在mysql自动建表数据会中文乱码现象
 * @author wj
 * @version 1.0
 */
public class MySQLDialect extends MySQL5Dialect {

    /**
     * 设置hibernate创建表的默认引擎和字符集
     */
    @Override
    public String getTableTypeString() {
        return " ENGINE=InnoDB DEFAULT CHARSET=utf8";
    }

    /**
     * 生成外键时执行代码,关闭hibernate创建表时设置外键
     */
    @Override
    public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) {
        return "";
        //return " drop foreign key " + constraintName;
    }

}
